DLSite Maniaxから書誌情報を取得するUserScript
code:js
// ==UserScript==
// @name DISC_DLSite_maniax
// @version 0.2
// @description Get a bibliography from DLSite
// @author Motoso Inami
// DLSiteはbabel-polififllを利用しているので多重に読み込む必要はない
// ==/UserScript==
var inline_src = (<><![CDATA[
var results = [];
const title = document.getElementById('work_name').innerText;
const table = document.getElementById('work_maker');
// optionals
// Get elements from table if string of left side is equal to "match"
const getElemIfExists = (leftHeaderStr) => {
const filtered = ...table.rows.filter((row) => row.cells0.innerText === leftHeaderStr) if(filtered.length > 0){
return filtered0.cells1.innerText; }else {
return null;
}
};
const outlineTable = document.getElementById('work_outline');
// optionals
// Get elements from table if string of left side is equal to "match"
// TODO: Merge to the above function
const getElemIfExistsFromOutline = (leftHeaderStr) => {
if(filtered.length > 0){
return filtered0.cells1.innerText; }else {
return null;
}
};
const url = document.location.href;
const author = getElemIfExistsFromOutline("作者");
const eventName = getElemIfExistsFromOutline("イベント");
// サークル名\nフォローする\n1234 -> サークル名
const circleName = getElemIfExists("サークル名").match(/(^.*)\r?\n/)1.trim(); // YYYY年MM月DD日 -> YYYY-MM-DD
const publishedAt = new Date(getElemIfExistsFromOutline("販売日").match(/(\d{4})年(\d{2})月(\d{2})日/).slice(1).join("-"));
const year = publishedAt.getFullYear();
const month = publishedAt.getMonth() + 1;
const day = publishedAt.getDate();
results.push(title);
results.push([DLSiteで読む ${url}]);
results.push([[サークル名]]:[${circleName}]);
results.push([[原作]]:);
results.push([[概要]]:);
results.push([[発行年]]:[${year}]/${month}/${day})
// テキストエリアを設置して描画
let textarea = document.createElement('textarea'); textarea.id = 'textarea'; textarea.rows = 11;
let header = document.getElementById('header'); header.appendChild(textarea);
let t = document.getElementById('textarea'); t.value = results.join('\n');
]]></>).toString();
eval(c.code);
更新履歴
2020/4/8 0.2 作家名とイベント名も表示